@use "../variables" as *;

.history-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: $sidebar-width;
  transform: translateX(-100%);
  transition: transform $transition-normal ease;
  z-index: $z-sidebar;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--border-weak);

  &.visible {
    transform: translateX(0);
  }

  .history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 $page-h-padding;

    @include scrollbar;
  }

  .history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 8px;

    &:hover {
      background: var(--bg-op-dark-ultraweak);

      .delete-btn {
        opacity: 1;
      }
    }

    &.active {
      background: rgba(var(--bg-pri-blue), 0.1);
    }

    .history-content {
      flex: 1;
      min-width: 0;
      margin-right: 8px;

      .history-title {
        font-weight: 500;
        margin-bottom: 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .history-date {
        font-size: 12px;
        color: var(--text-weak);
      }
    }

    .delete-btn {
      opacity: 0;
      padding: 4px;
      background: none;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      transition: all $transition-fast;

      &:hover {
        background: var(--bg-op-dark-ultraweak);
      }

      svg {
        width: 16px;
        height: 16px;
        fill: currentColor;
      }
    }
  }

  .history-header {
    padding: 16px $page-h-padding;
    
    .new-chat-btn {
      width: 100%;
      padding: 10px;
      border: none;
      border-radius: 8px;
      background: var(--bg-pri-blue);
      color: white;
      font-weight: 500;
      cursor: pointer;
      transition: background $transition-fast;
      
      &:hover {
        background: var(--bg-hover-blue);
      }
      
      &:active {
        background: var(--bg-active-blue);
      }
    }
  }

  .sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--border-weak);
    
    .update-btn {
      display: flex;
      align-items: center;
      justify-content: space-between;
      outline: var(--border-weak) 1px solid;
      
      & > div {
        display: flex;
        gap: 8px;
      }
      
      .update-btn-wrap {
        display: flex;
        align-items: center;
      }
      
      .update-btn-text {
        font-size: 12px;
      }
    }

    .sidebar-footer-btn {
      display: flex;
      align-items: center;
      gap: 8px;
      width: 100%;
      padding: 8px 12px;
      border: none;
      border-radius: 6px;
      background: none;
      color: inherit;
      cursor: pointer;
      transition: all $transition-fast;
      
      &:not(:first-child) {
        margin-top: 8px;
      }
      
      &:hover {
        background: var(--bg-op-dark-extremeweak);
      }

      svg {
        fill: var(--stroke-op-dark-extremestrong);
      }
    }

    .system-btn {
      svg {
        fill: none;
        color: var(--stroke-op-dark-extremestrong);
      }
    }
  }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: $z-modal;
}

.confirm-modal {
  background: var(--bg-weak);
  padding: 24px;
  border-radius: 8px;
  min-width: 300px;

  h3 {
    margin: 0 0 20px;
    text-align: center;
  }

  .confirm-actions {
    display: flex;
    justify-content: center;
    gap: 12px;

    button {
      padding: 8px 16px;
      border-radius: 6px;
      border: none;
      cursor: pointer;
      transition: all 0.2s;

      &.cancel-btn {
        background: none;
        border: 1px solid var(--border);
        color: var(--text);

        &:hover {
          border-color: var(--bg-hover-blue);
          color: var(--text-hover-blue);
        }
      }

      &.confirm-btn {
        background: var(--bg-error);
        color: white;

        &:hover {
          background: var(--bg-hover-error);
        }
      }
    }
  }
}